package com.cooldatasoft.domain.daoImpl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.cooldatasoft.domain.dao.DocumentEntryDao;
import com.cooldatasoft.domain.model.Document;
import com.cooldatasoft.domain.model.DocumentEntry;

public class DocumentEntryDaoImpl extends GenericDaoImpl<DocumentEntry, Long> implements DocumentEntryDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<DocumentEntry> getByDocument(Document document) {
		Criteria reservationCrit = getSession().createCriteria(DocumentEntry.class);
		reservationCrit.add(Restrictions.eq("document", document));
		
		List<DocumentEntry> res = reservationCrit.list();
		return (res.size() > 0) ? res : new ArrayList<DocumentEntry>();
	}

}
